const utils = {
  
  /*
    Mock up Article pic
  */
  mockUpArticlePic : function mockUpArticlePic(obj) {
    let picIndexRandomArray = [];
    for(let i = 0; i < 16; i++) {
      picIndexRandomArray.push(Math.floor((Math.random()) * 10 + 1));
    }

    obj.setData({
      picIndexRandomArray
    });
  },

  /*Define transfer the Number to Date for UI display*/
  transferLongToDate(articleList) {
    //Handle Created Time from Number to Date
    articleList.forEach(eachSwiperArticleList => {
      let eachListInSwiper = eachSwiperArticleList.list;
      if(eachListInSwiper) {
        eachListInSwiper.forEach(article => {
          article['createdTime'] = new Date(article['createdTime']).toLocaleString();
          article['modifyTimestamp'] = new Date(article['modifyTimestamp']).toLocaleString();

          // console.log(`article['createdTime'] ================ ${article['createdTime']}, article['modifyTimestamp'] =============== ${article['modifyTimestamp']}`);
        });
      };
    });

    return articleList;
  }
}

export {utils}